package org.ahuanlien.crm.web.controller;

import org.ahuanlien.crm.query.transferRecordQueryObject;
import org.ahuanlien.crm.service.ITransferRecordService;
import org.ahuanlien.crm.util.JSONResult;
import org.ahuanlien.crm.util.PageResult;
import org.ahuanlien.crm.vo.TransferRecordVO;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("transferRecord")
public class TransferRecordController {

	@Autowired
	private ITransferRecordService transferRecordService;

	//移交客户记录页面
	@RequestMapping("view")
	@RequiresPermissions(value = {"transferRecord:view", "移交客户记录页面"}, logical = Logical.OR)
	public String view() {
		return "transferRecord/view";
	}

	@RequestMapping("query")
	@RequiresPermissions(value = {"transferRecord:query", "移交客户记录列表"}, logical = Logical.OR)
	@ResponseBody
	public PageResult query(transferRecordQueryObject qo) {
		PageResult result = transferRecordService.query(qo);
		return result;
	}

	//新增客户移交记录
	@RequestMapping("insertTransferRecord")
	@ResponseBody
	public JSONResult insertTransferRecord(TransferRecordVO vo) {
		try {
			transferRecordService.insertTransferRecord(vo);
		} catch (Exception e) {
			e.printStackTrace();
			return JSONResult.mark("操作失败");
		}
		return JSONResult.success("操作成功");
	}
}
